import Vue from 'vue'
import App from '@/App.vue'
import loading from '@/app/loading'
import router from '@/app/router'
import store from "@/app/store";
import * as filters from '@/app/filter'
import ajax from "@/app/ajax";
import helper from "@/app/helper";
import api from "@/app/api";

Vue.use(loading);
Vue.config.productionTip = false;
Vue.prototype.$helper = helper;
Vue.prototype.$ajax = ajax;
Vue.prototype.$api = api;
window.$showLoading = function (title) {
  store.commit('showLoading', title)
};
window.$hideLoading = function () {
  store.commit('hideLoading')
};

//全局注册过滤器
Object.keys(filters).forEach(name => Vue.filter(name, filters[name]));

//路由跳转后回到顶部
router.afterEach((to, from, next) => {
  window.scrollTo(0, 0);
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app');